package com.example.module_project.presenter

import com.example.module_common.base.BaseModel
import com.example.module_common.base.BaseObserver
import com.example.module_common.base.BasePresenter
import com.example.module_common.model.ProjectListModel
import com.example.module_common.model.ProjectTitleModel
import com.example.module_project.view.ProjectView

/**
 * 作者： njb
 * 时间： 2021/5/12 23:42
 * 描述：
 */
class ProjectPresenter(projectView: ProjectView):BasePresenter<ProjectView>(projectView) {
    fun ProJectTitle(){
        addDisposable(apiServer.projectTree(), object : BaseObserver<BaseModel<List<ProjectTitleModel.DataBean>>>(baseView) {
            override fun onSuccess(o: BaseModel<List<ProjectTitleModel.DataBean>>) {
                baseView.onLoadProjectTree(o.data!!)
            }


            override fun onError(msg: String?) {
                baseView.showError(msg!!)

            }
        })
    }

    fun ProjectList(page:Int,cid:Int){
        addDisposable(apiServer.projectList(page,cid),object :BaseObserver<BaseModel<ProjectListModel>>(baseView){
            override fun onSuccess(o: BaseModel<ProjectListModel>) {
                baseView.onLoadProjectList(o.data!!)
            }

            override fun onError(msg: String?) {
               baseView.showError(msg!!)
            }

        })
    }
}